home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / mac / Software / entwickl / macos / python14.hqx / Python 1.4 PPC / Mac / Lib / test / ttedit.py < prev    next >
Text File  |  1996-04-15  |  2KB  |  82 lines

  1. # Test TE module.
  2. # Draw a window in which the user can type.
  3. #
  4. # This test expects Win, Evt and FrameWork (and anything used by those)
  5. # to work.
  6. #
  7. # Actually, it is more a test of FrameWork by now....
  8.  
  9. from FrameWork import *
  10. import Win
  11. import Qd
  12. import TE
  13. import os
  14.  
  15. class TEWindow(Window):
  16.     def open(self, name):
  17.         r = (40, 40, 400, 300)
  18.         w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555)
  19.         r2 = (0, 0, 345, 245)
  20.         Qd.SetPort(w)
  21.         self.ted = TE.TENew(r2, r2)
  22.         self.ted.TEAutoView(1)
  23.         w.DrawGrowIcon()
  24.         self.wid = w
  25.         self.do_postopen()
  26.         
  27.     def do_idle(self):
  28.         self.ted.TEIdle()
  29.         
  30.     def do_activate(self, onoff, evt):
  31.         if onoff:
  32.             self.ted.TEActivate()
  33.         else:
  34.             self.ted.TEDeactivate()
  35.  
  36.     def do_update(self, wid, event):
  37.         Qd.EraseRect(wid.GetWindowPort().portRect)
  38.         self.ted.TEUpdate(wid.GetWindowPort().portRect)
  39.         
  40.     def do_contentclick(self, local, modifiers, evt):
  41.         shifted = (modifiers & 0x200)
  42.         self.ted.TEClick(local, shifted)
  43.  
  44.     def do_char(self, ch, event):
  45.         self.ted.TEKey(ord(ch))
  46.  
  47. class TestList(Application):
  48.     def __init__(self):
  49.         Application.__init__(self)
  50.         self.num = 0
  51.         self.listoflists = []
  52.         
  53.     def makeusermenus(self):
  54.         self.filemenu = m = Menu(self.menubar, "File")
  55.         self.newitem = MenuItem(m, "New window...", "O", self.open)
  56.         self.quititem = MenuItem(m, "Quit", "Q", self.quit)
  57.     
  58.     def open(self, *args):
  59.         w = TEWindow(self)
  60.         w.open('Window %d'%self.num)
  61.         self.num = self.num + 1
  62.         self.listoflists.append(w)
  63.         
  64.     def quit(self, *args):
  65.         raise self
  66.  
  67.     def do_about(self, id, item, window, event):
  68.         EasyDialogs.Message("""Test the TextEdit interface.
  69.         Simple window in which you can type""")
  70.         
  71.     def do_idle(self, *args):
  72.         for l in self.listoflists:
  73.             l.do_idle()
  74.  
  75. def main():
  76.     App = TestList()
  77.     App.mainloop()
  78.     
  79. if __name__ == '__main__':
  80.     main()
  81.     
  82.